package dao

import "github.com/garyburd/redigo/redis"

// AddFollowee 增加关注对象，以ZSet为存储类型，时间戳记为score，本人为key，关注者为value
func (*followDAO) AddFollowee(conn redis.Conn, followeeKey string, nowMillSecond int64, toUserId int64, err error) error {
	err = conn.Send("ZADD", followeeKey, nowMillSecond, toUserId)
	if err != nil {
		return err
	}
	return nil
}

// AddFollower 增加关注对象的粉丝，以ZSet为存储类型，时间戳记为score，关注者为key，本人为value
func (*followDAO) AddFollower(conn redis.Conn, followerKey string, nowMillSecond int64, userId int64, err error) error {
	err = conn.Send("ZADD", followerKey, nowMillSecond, userId)
	if err != nil {
		return err
	}
	return nil
}

// RemFollowee 删除关注对象
func (*followDAO) RemFollowee(conn redis.Conn, followeeKey string, toUserId int64, err error) error {
	err = conn.Send("ZREM", followeeKey, toUserId)
	if err != nil {
		return err
	}
	return nil
}

// RemFollower 删除对象的粉丝
func (*followDAO) RemFollower(conn redis.Conn, followerKey string, userId int64, err error) error {
	err = conn.Send("ZREM", followerKey, userId)
	if err != nil {
		return err
	}
	return nil
}
